/******************************************************************/
/*                    DoFile Replication file
	Review of Economics and Statistics
	
		Victim incentives and criminal activity: 
		Evidence from bus driver robberies in Chile   		  
			
			Author: Patricio Domínguez
			September, 2020										  */

/******************************************************************/

/* Notes: This dofile generates Table 5 */

set scheme plotplain

/******************************************************************/
/*                    Set directory structure          		      */ 
/******************************************************************/

global rep "/Users/patriciodominguez/RES_Dominguez Dropbox/Patricio Dominguez/Replication/TS"

use "$rep/dta/value_good.dta", clear

rename jan_05oct_05 Pre
rename nov_05jan07 Transition
rename feb07dec10 Post
 
label variable Pre "Robberies Pre-reform"
label variable Transition "Robberies Transition"
label variable Post "Robberies Post-reform"
label variable value "Value range category"

bys cash: egen crime_pre = total(Pre)
bys cash: egen crime_tra = total(Transition)
bys cash: egen crime_post = total(Post)

* Proportion of incidents per period
g prop_inc_pre = Pre/crime_pre
g prop_inc_tra = Transition/crime_tra
g prop_inc_post = Post/crime_post

g no_value=value=="No value"
g yes_value= no_value==0
replace yes_value=. if no_value==1

g pre_v = Pre*yes_value
g tra_v = Tra*yes_value

bys cash: egen crime_pre2 = total(pre_v)
bys cash: egen crime_tra2 = total(tra_v)

g prop_inc_V_pre = pre_v/crime_pre2
g prop_inc_V_tra = tra_v/crime_tra2

g order =0 if value=="No value"
replace order =1 if value=="$10k to $50k"
replace order =2 if value=="$50k to $100k"
replace order =3 if value=="$100k to $250k"
replace order =4 if value=="> $250k"

sort cash order 

// Calculating robberies per week for each period: dividing by # weeks on each period
g pre_week = crime_pre/42
g tra_week = crime_tra/68


****** Table 5
* Panel A
table order if cash==1, c(mean prop_inc_pre mean prop_inc_V_pre mean prop_inc_tra mean prop_inc_V_tra) format(%9.3fc)
qui su pre_week if cash==1
di `r(mean)'
qui su tra_week if cash==1
di `r(mean)'

* Panel B
table order if cash==0, c(mean prop_inc_pre mean prop_inc_V_pre mean prop_inc_tra mean prop_inc_V_tra) format(%9.3fc)
qui su pre_week if cash==0
di `r(mean)'
qui su tra_week if cash==0
di `r(mean)'
